//
//  CZMyLotteryController.m
//  A01-CZ彩票
//
//  Created by apple on 15-6-14.
//  Copyright (c) 2015年 itcast. All rights reserved.
//

#import "CZMyLotteryController.h"
#import "CZLoginController.h"
#import "UIImage+Ex.h"
#import "CZSettingsController.h"
#import "CZQuestionController.h"
@interface CZMyLotteryController ()
@property (weak, nonatomic) IBOutlet UIButton *loginView;
@property (weak, nonatomic) IBOutlet UIBarButtonItem *configItem;

@end

@implementation CZMyLotteryController
//点击登录按钮
- (IBAction)loginClick:(id)sender {
    
    //创建登录控制器
    CZLoginController *vc = [CZLoginController new];
    vc.view.backgroundColor = [UIColor whiteColor];
    vc.title = @"登录";
    
  //设置后退按钮
    UIBarButtonItem *back = [[UIBarButtonItem alloc] initWithTitle:@"取消" style:UIBarButtonItemStylePlain target:self action:@selector(backClick)];
    vc.navigationItem.leftBarButtonItem = back;
      //创建导航控制器
    UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:vc];
    
    [self presentViewController:navController animated:YES completion:nil];
    
}

- (void)backClick{
    [self dismissViewControllerAnimated:YES completion:nil];
}

//点击设置按钮
- (IBAction)configClick:(id)sender {
    CZSettingsController *vc = [[CZSettingsController alloc] init];
    vc.title = @"设置";
    
    //常见问题
    UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithTitle:@"常见问题" style:UIBarButtonItemStylePlain target:self action:@selector(questionClick)];
    vc.navigationItem.rightBarButtonItem = item;
    
    
    [self.navigationController pushViewController:vc animated:YES];
}

//点击常见问题
- (void)questionClick{
    CZQuestionController *vc = [CZQuestionController new];
    
    [self.navigationController pushViewController:vc animated:YES];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    //去掉设置按钮的图片蒙版
    self.navigationItem.rightBarButtonItem.image = [self.navigationItem.rightBarButtonItem.image originalImage];
    
    
    
    UIImage *img = [UIImage imageNamed:@"RedButton"];
    UIImage *selImg = [UIImage imageNamed:@"RedButtonPressed"];
    
    //拉伸图片
    img = [img stretchableImageWithLeftCapWidth:img.size.width/2 topCapHeight:img.size.height/2];
    
    [self.loginView setBackgroundImage:img forState:UIControlStateNormal];
    [self.loginView setBackgroundImage:selImg forState:UIControlStateHighlighted];
}

@end
